<table width="100%" border="1" cellspacing="5" cellpadding="5" class="tbl_border">
  <tr>
    <td bgcolor="#3399FF"><form id="form2" name="form1" method="post" action="index.php?page=char_filter&&cattegory"><select name="filter_cat" id="filter_cat">
        <?php
		if(isset($_POST['filter_cat'])){
			if($_POST['filter_cat'] == 'all'){
		?>
        <option value="all" selected="selected">All</option>
        <option value="charachter">Charachter</option>
        <option value="head">Head</option>
        <?php
			}elseif($_POST['filter_cat'] == 'charachter'){
		?>
        <option value="all" >All</option>
        <option value="charachter" selected="selected">Charachter</option>
        <option value="head">Head</option>
        <?php
			}elseif($_POST['filter_cat'] == 'head'){
		?>
        <option value="all" >All</option>
        <option value="charachter" >Charachter</option>
        <option value="head" selected="selected">Head</option>
        <?php
			}
		}else{
		?>
        <option value="all">All</option>
        <option value="charachter">Charachter</option>
        <option value="head" >Head</option>
        <?php
		}
		?>
      </select>
      <input type="submit" name="button4" id="button4" value="Filter" />
    </form></td>
    <td width="23%" align="center" bgcolor="#3399FF"><a href="index.php?page=add_char"><img src="assets/image/add_btn.png" width="50" height="51" alt="Add" /></a></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#3399FF">&nbsp;</td>
    <td align="center" bgcolor="#3399FF"><form name="form1" method="post" action="index.php?page=char_filter&amp;&amp;pencarian">
      <input type="text" name="search" id="search">
      <input type="submit" name="button" id="button" value="Search">
    </form></td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="1" cellspacing="4" cellpadding="4">
      <tr>
        <td>#</td>
        <td><a href="index.php?page=char">Picture</a></td>
        <td><a href="index.php?page=char_filter&&sharingan=char_name&&opsi=<?php if($_GET['opsi'] == 'asc'){ echo"desc"; }elseif($_GET['opsi'] == 'desc'){ echo"asc"; }else{ echo"asc"; } ?>
        ">Char Name</a></td>
        <td><a href="index.php?page=char_filter&&sharingan=cattegory&&opsi=<?php if($_GET['opsi'] == 'asc'){ echo"desc"; }elseif($_GET['opsi'] == 'desc'){ echo"asc"; }else{ echo"asc"; } ?>">Cattegory</a></td>
        <td><a href="index.php?page=char_filter&&sharingan=mark&&opsi=<?php if($_GET['opsi'] == 'asc'){ echo"desc"; }elseif($_GET['opsi'] == 'desc'){ echo"asc"; }else{ echo"asc"; } ?>">Mark</a></td>
        <td>Duration &amp; Price</td>
        <td>Description</td>
        <td><a href="index.php?page=char_filter&&sharingan=status&&opsi=<?php if($_GET['opsi'] == 'asc'){ echo"desc"; }elseif($_GET['opsi'] == 'desc'){ echo"asc"; }else{ echo"asc"; } ?>">Status</a></td>
        <td>Config</td>
      </tr><?php
if(isset($_GET['pencarian'])){
	$search = $_POST['search'];
	$kueri = mysql_query("select * from tbl_char where char_name LIKE '%$search%'");
}elseif(isset($_GET['cattegory'])){
	$filter_cat = $_POST['filter_cat'];
	echo"<div align=\"center\"><font size=\"5\">Filter $filter_cat</font></div>";
	if($filter_cat == 'all'){
		$kueri = mysql_query("select * from tbl_char order by char_name asc");	
	}else{
		$kueri = mysql_query("select * from tbl_char where cattegory = '$filter_cat'");
	}
}else{
	$sharingan = $_GET['sharingan'];
	$opsi = $_GET['opsi'];
	$kueri = mysql_query("select * from tbl_char ORDER BY $sharingan $opsi");
}
$kueri_row = mysql_num_rows($kueri);
//echo $kueri_row;
if($kueri_row == 0){
?>
	<tr>
        <td>-</td>
        <td>-</td>
        <td>-</td>
        <td>-</td>
        <td>-</td>
        <td>-</td>
        <td>-</td>
        <td>-</td>
        <td>-</td>
      </tr>
<?php
}else{
	$no=0;
	$setrip = "&nbsp;-&nbsp;";
	while($data = mysql_fetch_array($kueri))
	{
		$no++;
		if($no%2){
			$pelangi = "class=\"ganjil\"";	
		}else{
			$pelangi = "class=\"genap\"";	
		}
	?>
		<tr <?=$pelangi;?>>
		  <td align="center"><?=$no;?></td>
		  <td>
		  <?php
		  if($data['id_char'] == NULL){
			echo $setrip;  
		  }else{
		  ?>
		  <a href="index.php?page=edit_char&&id=<?=$data['id_char'];?>">
		  <img alt="Picture" width="242px" src="assets/picture/<?=$data['picture'];?>" />
		  </a>
		  <?php
		  }
		  ?>
		  </td>
		  <td class="judul"><font color="#FF0000"><?=$data['char_name'];?></font></td>
		  <td align="center">
          <?php
		  if($data['cattegory'] == 'charachter'){
			echo "Charachter";  
		  }elseif($data['cattegory'] == 'head'){
			  echo "Head"; 
		  }
		  ?>
          </td>
		  <td align="center">
		  <?php
		  if($data['mark'] == "hot"){
			echo "HOT";  
		  }elseif($data['mark'] == "new"){
			echo "NEW";  
		  }elseif($data['mark'] == "regular"){
			echo "REGULAR";  
		  }else{
			echo"ERROR";  
		  }	
		  ?>
		  </td>
		  <td align="center">
		  <?php
				echo "1 Day : $data[one_day] <br />3 Day : $data[three_day] <br />7 Day : $data[seven_day] <br />30 Day : $data[thirty_day]";
		  ?></td>
		  <td align="center"><?=$data['description'];?></td> 
		  <td align="center">
		  <?php
		  if($data['status'] == "sell"){
			echo "SELL";  
		  }elseif($data['status'] == "not_sell"){
			echo "NOT SELL";  
		  }else{
			echo"ERROR";  
		  }	
		  ?>
		  </td>
		  <td align="center"><a href="index.php?page=edit_char&&id=<?=$data['id_char'];?>">Edit</a><br /><a href="delete_char.php?id=<?=$data['id_char']; ?>">Delete</a></td>
		</tr>
		<?php
	}
}
	?>
    </table></td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>
